import pytest
import requests

from api import log
from api.api_approve_trust import ApiApproveTrust
from api.api_recharge import ApiRecharge
from api.api_register_login import ApiRegisterLogin
from api.api_tender import ApiTender
from tool import clear_data



@pytest.fixture(scope='session')
def api_client():
    session=requests.session()
    clear_data()
    log.info(f"正在获取session对象 {session}")
    log.info(f"正在清除数据")
    yield ApiRegisterLogin(session)
    session.close()
    log.info(f"关闭session对象 {session}")

@pytest.fixture(scope='session')
def api_client1():
    session=requests.session()
    log.info(f"正在获取session对象 {session}")
    ApiRegisterLogin(session).api_login(15612345678,"123456a")
    yield ApiApproveTrust(session)
    session.close()
    log.info(f"关闭session对象 {session}")

@pytest.fixture(scope='session')
def api_client2():
    session=requests.session()
    log.info(f"正在获取session对象 {session}")
    ApiRegisterLogin(session).api_login(15612345678,"123456a")
    yield ApiRecharge(session)
    session.close()
    log.info(f"关闭session对象 {session}")

@pytest.fixture(scope='session')
def api_client3():
    session=requests.session()
    log.info(f"正在获取session对象 {session}")
    ApiRegisterLogin(session).api_login(15612345678,"123456a")
    yield ApiTender(session)
    session.close()
    log.info(f"关闭session对象 {session}")


